package lzc.demo.spring.eureka.server;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

/**
 * 程序启动入口
 *
 */
@SpringBootApplication // springBoot注解,spring在springBoot基础之上来构建项目
@EnableZuulProxy // zuul 代理
public class App {

	@Bean
	public PatternServiceRouteMapper serviceRouteMapper() {
		// spring.application.name = [微服务名称]-v[版本数] ==》 v[版本数]/[微服务名称]
		// 没有匹配到，则用默认缺省的访问方式
		return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)", "${version}/${name}");
	}

	// spirng boot的标准入口
	public static void main(String[] args) {
		new SpringApplicationBuilder(App.class).web(true).run(args);
	}

}
